<ui:composition template="/tema/template.xhtml"
		xmlns="http://www.w3.org/1999/xhtml"
		xmlns:ui="http://java.sun.com/jsf/facelets"
		xmlns:h="http://java.sun.com/jsf/html"
		xmlns:f="http://java.sun.com/jsf/core"
		xmlns:p="http://primefaces.org/ui">
	<ui:define name="corpo_pagina">	
		<ui:decorate template="/tema/template_cadastro.xhtml">		
			<!-- Os bean e as classes -->
			<ui:param name="mbean" value="${beanCliente}" />
			
			<!-- ação dos botões -->
			<ui:param name="actionGravar"   value="gravar"/>															
			<ui:param name="actionExcluir"  value="excluir"/>
			<ui:param name="actionCancelar" value="limpar"/>
			
			<!-- Tamanho do formulário -->
			<ui:param name="tm" value="830px" />
			
			<!-- Campos da Grid -->
			<ui:param name="titulo_grid" value="Cadastro de Cliente"/>			
			
			<ui:define name="campos">			
				<p:messages />
				<h:panelGrid id="pnlNovo" columns="2" cellpadding="2">     
			    	<h:outputText for="nome" value="Nome: * " />
			    	<p:inputText id="novNome" size="50" value="#{beanCliente.cliente.nome}" required="false"/>
			    	<h:outputText for="cnpj_cpf" value="Cnpj/Cpf: * " />
			    	<p:inputText id="novCnpj_cpf" size="20" value="#{beanCliente.cliente.cnpj_cpf}" required="false"/>
			    	<h:outputText for="dtCadastro" value="Dt de Cadastro: * " />
			    	<p:calendar value="#{beanCliente.cliente.dtcad}" id="popupButtonCal" showOn="button" required="false"/> 							    	
				</h:panelGrid>									
			</ui:define>
	
			<ui:define name="grid">
				<p:dataTable id="dataTable" var="v" value="#{beanCliente.listar}"  emptyMessage="Não há clientes com critério de busca." loadingMessage="Buscando..."
		             paginator="true" rows="5" rowKey="#{v.codigo}" rowsPerPageTemplate="5,10" widgetVar="grupoTable" styleClass="tabela" headerClass="cabecalho"
		 			 paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" 
		             selection="#{beanCliente.selectedCliente}" selectionMode="single" filteredValue="#{beanCliente.filtrarCliente}">			            
					
					<p:column styleClass="coluna1" sortBy="#{v.codigo}" filterBy="#{v.codigo}" filterMatchMode="contains"  footerText="Código">
						<f:facet name="header">Código</f:facet>
						
						<h:outputText value="#{v.codigo}"/>
					</p:column>
					<p:column styleClass="coluna2" sortBy="#{v.nome}" filterBy="#{v.nome}" filterMatchMode="contains" headerText="Nome do Cliente">
						<h:outputText value="#{v.nome}" />
					</p:column>
					<p:column styleClass="coluna2" sortBy="#{v.cnpj_cpf}" filterBy="#{v.cnpj_cpf}" filterMatchMode="contains" headerText="Cnpj/Cpf">
						<h:outputText value="#{v.cnpj_cpf}" />
					</p:column>
					<p:column styleClass="coluna1" sortBy="#{v.dtcad}" filterBy="#{v.dtcad}" filterMatchMode="contains" headerText="Dt Cadastro">
						<h:outputText value="#{v.dtcad}" >
							<f:convertDateTime pattern="dd/MM/yyyy"/> 
						</h:outputText>
					</p:column>	
					<p:column headerText="Editar" oncomplete="#{beanCliente.selectedCliente}" title="Editar Registro" filterMatchMode="contains" >    
             			<h:commandLink id="editar" actionListener="#{beanCliente.editar}" value="Editar" update=":frmCadastro:pnlInserir"/>              			    
         			</p:column>        																								
			</p:dataTable>  
			</ui:define>
											
		</ui:decorate>
	</ui:define>
</ui:composition>
